﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Com.LongER.Framework.Utils;
using Com.LongER.Business.ZHM010;
using Com.LongER.Business.ZHM010.ZHM010DSTableAdapters;
using System.Data.SqlClient;
using System.Data;
using System.Collections;
using Com.LongER.Framework.Utils.LogUtils;

namespace Com.LongER.Business.ZHM010
{
    public class CZHM010 : ABussinessBase
    {
        private Log log = Log.GetInstance();

        /// <summary>
        /// 获取客户详细信息的值
        /// </summary>
        /// <returns></returns>
        public ZHM010DS.M_KEHUDETAILDataTable GetMKehuDetail(String strKehu_Cd)
        {
            String connectionString = ConnectionStringUtil.GetConnectionString();
            M_KEHUDETAILTableAdapter ta = new M_KEHUDETAILTableAdapter(connectionString);

            ZHM010DS.M_KEHUDETAILDataTable tb = ta.GetData(strKehu_Cd);
            ta.Connection.Close();
            return tb;
        }

        /// <summary>
        /// 追加客户详细信息的值
        /// </summary>
        /// <returns></returns>
        public Boolean InsertMKehu(String strNewKEHU_CD, String strNewKEHU_HANZI, String strNewSHO,
                                   String strNewHEZUO_XINGZHI, String strNewGONGSI_ADDR, String strNewPOST,
                                   String strNewGONGSI_XINGZHI, String strNewLIANXI_REN, String strNewZHENGJIAN_ZB,
                                   String strNewTEL_NUM1, String strNewZHENGJIAN_NUM,
                                   String strNewTEL_NUM2, String strNewFAX1, String strNewFAX2, String strNewMAIL_ADDR,
                                   String strNewYINHANG1, String strNewYH_CARD_ZB1, String strNewYH_CARD_NUM1,
                                   String strNewYINHANG2, String strNewYH_CARD_ZB2, String strNewYH_CARD_NUM2,
                                   String strNewYINHANG3, String strNewYH_CARD_ZB3, String strNewYH_CARD_NUM3,
                                   String strNewZHIFU_FANGSHI, String strNewBEIZHU)
        {
            String connectionString = ConnectionStringUtil.GetConnectionString();
            M_KEHUDETAILTableAdapter ta = new M_KEHUDETAILTableAdapter(connectionString);

            int result = ta.InsertM_KEHU(strNewKEHU_CD, strNewKEHU_HANZI, strNewSHO,
                                   strNewHEZUO_XINGZHI, strNewGONGSI_ADDR, strNewPOST,
                                   strNewGONGSI_XINGZHI, strNewLIANXI_REN, strNewZHENGJIAN_ZB,
                                   strNewTEL_NUM1, strNewZHENGJIAN_NUM,
                                   strNewTEL_NUM2, strNewFAX1, strNewFAX2, strNewMAIL_ADDR,
                                   strNewYINHANG1, strNewYH_CARD_ZB1, strNewYH_CARD_NUM1,
                                   strNewYINHANG2, strNewYH_CARD_ZB2, strNewYH_CARD_NUM2,
                                   strNewYINHANG3, strNewYH_CARD_ZB3, strNewYH_CARD_NUM3,
                                   strNewZHIFU_FANGSHI, strNewBEIZHU);
            ta.Connection.Close();
            if (result > 0) return true;

            return false;
        }

        /// <summary>
        /// 更新客户表
        /// </summary>
        /// <param name="strUserId"></param>
        /// <param name="strPassword"></param>
        /// <returns></returns>
        public Boolean UpdateMKehu(String strKEHU_HANZI, String strNewSHO,String strNewHEZUO_XINGZHI, 
                                       String strNewGONGSI_ADDR,String strNewPOST, 
                                       String strNewGONGSI_XINGZHI,String strNewLIANXI_REN, 
                                       String strNewZHENGJIAN_ZB,String strNewZHENGJIAN_NUM, 
                                       String strNewTEL_NUM1,String strNewTEL_NUM2, 
                                       String strNewFAX1, String strNewFAX2,String strNewMAIL_ADDR,
                                       String strNewYINHANG1, String strNewYH_CARD_ZB1, String strNewYH_CARD_NUM1,
                                       String strNewYINHANG2, String strNewYH_CARD_ZB2, String strNewYH_CARD_NUM2,
                                       String strNewYINHANG3, String strNewYH_CARD_ZB3, String strNewYH_CARD_NUM3,
                                       String strNewZHIFU_FANGSHI,
                                       String strNewKEHU_CD)
        {
            String connectionString = ConnectionStringUtil.GetConnectionString();
            M_KEHUDETAILTableAdapter ta = new M_KEHUDETAILTableAdapter(connectionString);

            int result = ta.UpdateM_KEHU(strKEHU_HANZI, strNewSHO, strNewHEZUO_XINGZHI,
                                       strNewGONGSI_ADDR, strNewPOST,
                                       strNewGONGSI_XINGZHI, strNewLIANXI_REN,
                                       strNewZHENGJIAN_ZB, strNewZHENGJIAN_NUM,
                                       strNewTEL_NUM1, strNewTEL_NUM2,
                                       strNewFAX1, strNewFAX2, strNewMAIL_ADDR,
                                       strNewYINHANG1, strNewYH_CARD_ZB1, strNewYH_CARD_NUM1,
                                       strNewYINHANG2, strNewYH_CARD_ZB2, strNewYH_CARD_NUM2,
                                       strNewYINHANG3, strNewYH_CARD_ZB3, strNewYH_CARD_NUM3,
                                       strNewZHIFU_FANGSHI,
                                       strNewKEHU_CD);
            if (result <= 0) return false;
            ta.Connection.Close();

            if (result > 0) return true;

            return false;
        }

        /// <summary>
        /// 删除客户信息
        /// </summary>
        /// <returns></returns>
        public Boolean DeleteMKehu(String strNewKEHU_CD)
        {
            String connectionString = ConnectionStringUtil.GetConnectionString();
            M_KEHUDETAILTableAdapter ta = new M_KEHUDETAILTableAdapter(connectionString);

            int result = ta.DeleteM_KEHU(strNewKEHU_CD);
            ta.Connection.Close();
            if (result > 0) return true;

            return false;
        }


    }
}
